/**********************************************************************************************/
/* VSQL_I_Cursor.h																			  */
/*                                                                       					  */
//* Copyright Paradigma, 1993-2006															  */
/* All Rights Reserved.                                                 					  */
/**********************************************************************************************/

#ifndef _VSQL_I_Cursor_h
   #define _VSQL_I_Cursor_h
#pragma once

#include <VShared/VSQL/Headers/VSQL.h>

#include <VShared/FBL/publ/Interfaces/FBL_I_Table.h>

// FINAL:
#include <VShared/FBL/publ/Headers/FBL_pre_header.h>

 
/**********************************************************************************************/
VSQL_Begin_Namespace


/**********************************************************************************************/
SMART_INTERFACE(I_Cursor);
 

/**********************************************************************************************/
SMART_ARRAY_OF_SMART_PTRS( ArrayOfCursors, I_Cursor_Ptr );
SMART_ARRAY_OF_CLASS_PTRS( ArrayOfCursorsPointers, I_Cursor* );


/**********************************************************************************************/
// Interface I_Cursor -- result of SQL query.
//
// Result of SQL query always is a Table, so we inherit I_Cursor from I_Table to join 
// methods of both interfaces in one.
//
//StubInterface
interface FBL_SHARED_EXP_CLASS I_Cursor : public I_Table
{

virtual							~I_Cursor( void );

	// ---------------------
	// Properties:
								// Returns read only state.
virtual	bool					get_IsReadOnly( void ) const throw() = 0;	

								// Returns true if this is able to perform insert.
virtual	bool					CanInsert( void ) const throw() = 0;	

								// Returns true if this is able to perform update.
virtual	bool					CanUpdate( void ) const throw() = 0;	

								// Returns true if this is able to perform delete.
virtual	bool					CanDelete( void ) const throw() = 0;	

								// Returns error number.
virtual	long					get_Error( void ) const throw() = 0;		

								// Return the table which cursor is built over.
virtual I_Table_Ptr				get_Table( void ) const throw() = 0;

virtual void					put_Table( I_Table_Ptr inTable ) throw() = 0;


	// ---------------------
	// Record Navigation methods ODBC style:
	

virtual bool					FirstRecord_ODBC( void ) = 0;
virtual bool 					LastRecord_ODBC( void ) = 0;

virtual bool 					NextRecord_ODBC( void ) = 0;
virtual bool 					PrevRecord_ODBC( void ) = 0; 


	// ---------------------
	// SQL Methods:

								// Prepare SQL query for execution: parse it, optimise, ...
								// As result is built tree of nodes ready for execution.
virtual	long					Prepare( const String& inQuery ) = 0;
								
								// Execute prepared sql query as many times as you need.
								// Actually have sense if you use '?' parameters in the query.
virtual	long					Execute( void ) = 0;


	// ---------------------
 	// Record methods:
 	
virtual POSITION				get_Position( void ) const throw() = 0;

virtual bool					put_Position( POSITION inPosition ) = 0;
 	
								// Is this cursor an owner of table.
virtual void					put_OwnsTable( I_Table_Ptr inTable ) throw() = 0;

virtual void 					put_OwnsCursor( I_Cursor_Ptr inCursor ) throw() = 0;

								// Delete current record.
virtual	void					DropRecord( void ) = 0;

								// Reduce the number of records in the Selection
virtual	void					ReduceSelection( ulong inLimitRows, ulong inLimitOffset  ) = 0;

								// ArraySet cursor's data representation.
								// Contains RecIDs of the original table.
								// Return NULL in join case.
								// There is always new ArraySet returned.
								//
virtual ArraySet_Ptr 			ToArraySet( void ) = 0;

};


/**********************************************************************************************/
VSQL_End_Namespace

#include <VShared/FBL/publ/Headers/FBL_post_header.h>

#endif // _VSQL_I_Cursor_h



